<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div id="app">
    {{ num }}
    <br>
    <button @click="doubleNum = 40">直接修改计算属性</button>
    {{ doubleNum }}
  </div>
  <script src="./vue.js"></script>
  <script>
    const vm = new Vue({
      el: '#app',
      data: {
        num: 10
      },
     
      computed: {
        doubleNum:{
          get(){
            return this.num * 2;
          },
          set(val){
            // setter 直接给计算属性赋值时触发 参数 是 赋的值
            // console.log('计算属性赋值了值是',val);
            this.num = val / 2;
          }
        }
      }
    })
    console.log(vm);
  </script>
</body>
</html>